package com.ladlee.parking.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ladlee.parking.entity.SysParking;
import com.ladlee.parking.entity.vo.ParkingVo;
import com.ladlee.parking.mapper.SysParkingMapper;
import com.ladlee.parking.service.SysParkingService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
@AllArgsConstructor
public class SysParkingServiceImpl extends ServiceImpl<SysParkingMapper, SysParking> implements SysParkingService {

    private final HttpServletRequest request;

    @Override
    public Page<ParkingVo> parkingPage(String key, Integer page, Integer rows) {
        List<ParkingVo> records = this.baseMapper.selectParkingList(key, (page - 1) * rows, rows);
        Long total = this.baseMapper.selectParkingListTotal(key);
        Page<ParkingVo> pageInfo = new Page<>(page, rows);
        pageInfo.setTotal(total);
        pageInfo.setRecords(records);
        return pageInfo;
    }
}
